package com.bgs.controller;


import com.bgs.client.StoreCline;
import com.bgs.common.R;
import com.bgs.pojo.vo.FourOrderDetail;
import com.bgs.pojo.vo.ZeroToReportAndOrderDetail;
import com.bgs.service.OrderDetailService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.bgs.pojo.OrderDetail;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.bgs.pojo.Picture;
import com.bgs.pojo.StoreTow;
import com.bgs.pojo.vo.OrderDetailTow;
import com.bgs.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;

import com.bgs.pojo.OrderDetail;

import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 商品详情表 前端控制器
 * </p>
 *
 * @author Asia
 * @since 2021-09-14
 */
@RestController
@RequestMapping("/bgs/order-detail")
public class OrderDetailController {
    @Autowired
    private OrderDetailService orderDetailService;

    @Autowired
    private StoreCline storeCline;

    @GetMapping("zeroOrderDetailIdToOrderDetail/{orderDetailId}")
    public List<OrderDetail> zeroOrderDetailIdToOrderDetail(@PathVariable("orderDetailId") Integer orderDetailId) {
        return orderDetailService.zeroOrderDetailIdToOrderDetail(orderDetailId);
    }
    //对商品进行违规封禁，状态为4
    @GetMapping("zeroOrderDetailState4")
    public R zeroOrderDetailState4(Integer orderDetailId){
        return orderDetailService.zeroOrderDetailState4(orderDetailId);
    }

    /**
     * 后台商品审核查看
     * @return
     */
    @GetMapping("/TowGettableDataShang")
    public R TowGettableDataShang(String orderDetailName,Integer storeId){
        List<OrderDetail> list = orderDetailService.TowGettableDataShang(orderDetailName,storeId);
        return R.ok().data("list",list);
    }

    /**
     * 后台商品审核通过
     * @param orderDetailId
     * @return
     */
    @GetMapping("/TowShangShen")
    public R TowShangShen(Integer orderDetailId){
        int i = orderDetailService.TowShangShen(orderDetailId);
        return R.ok().data("i",i);
    }

    /**
     * 后台审核不通过
     * @return
     */
    @GetMapping("/TowShangShenNo")
    public R TowShangShenNo(Integer orderDetailId){
        int i = orderDetailService.TowShangShenNo(orderDetailId);
        return R.ok().data("i",i);
    }
    //圈子远程调用
    @GetMapping("/TowGetOrderDetail")
    public List<OrderDetailTow> TowgetOrderDetail(Integer orderDetailId){
        List<OrderDetailTow> list = orderDetailService.TowgetOrderDetail(orderDetailId);
        list.stream().forEach(x->{
            List<Picture> list1 = orderDetailService.TowGetPictures(x.getOrderDetailId());
            x.setPictures(list1);
        });
        return list;
    }
    //服务调用查看所有商品
    @GetMapping("/TowOrderList")
    public List<OrderDetail> TowOrderList(Integer storeId){
        List<OrderDetail> list = orderDetailService.TowOrderList(storeId);
        return list;
    }


    @GetMapping("/fourOpenShop")
    public R fourOpenShop(Integer id,Integer shangpinid){
        return orderDetailService.fourOpenShop(id,shangpinid);
    }

    /**
     * 上架物品
     * @param fourOrderDetail
     * @return
     */
    @PostMapping("/fourAddWupin")
    public R fourAddWupin(@RequestBody FourOrderDetail fourOrderDetail){
        return orderDetailService.fourAddWupin(fourOrderDetail);
    }

    /**
     * 查询物品详情
     */
    @GetMapping("/fourQueryDetail")
    public R fourQueryDetail(int id) {
        return orderDetailService.fourQueryDetail(id);
    }

    /*查询所有商品（主页面展示）*/
    @GetMapping("/fourIndexShow")
    public R fourIndexShow() {
        return orderDetailService.fourIndexShow();
    }

    @PostMapping("/ThreeSelectDetail")
    public R ThreeSelectDetail(@RequestBody List<OrderDetail> list) {
        return orderDetailService.ThreeSelectDetail(list);
    }
}

